<?php


namespace Admin\Model;

use Think\Model;

class PermissionModel extends Model{
    protected $tableName = "permission";

    public function lists(){
        $res = M("permission  as p")
            ->join("wp_permission_group as pg on p.permission_group = pg.id ")
            ->field("p.* , pg.group_name as group_name")    
            ->select();
        if(false !== $res){
            return $res;
        }
    }
    
    public function Find($id){
        $res = M("permission")
            ->where("id='$id'")    
            ->find(); 
        if(false !== $res){
            return $res;
        }
    }
    
    public function groupinfo(){
        $res = M("permission_group")
            ->field("id,group_name")   
            ->select(); 
        if(false !== $res){
            return $res;
        }
    }    
    
    public function editList(){
        $this->create();
        return $this->save();        
    }
    
    public function addList($data){
        return $this->add($data);
    }

    public function deleteList($id){
        if(!$id)return;
        return $this->delete($id);
    }    
    
}